package com.tgz.config;

import com.tgz.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Object ArithmeticException(HttpServletRequest req, Exception e) {
        log.error(e.getMessage(), e);
        return R.responseWithMessageError(e.getMessage());
    }

}
